/**
 * 
 */
package org.apache.hadoop.io;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;

/**
 * @author tim
 */
public class LongWritable implements WritableComparable {
	protected long l;
	public LongWritable(long l) {
		this.l = l;
	}

	public void readFields(DataInputStream in) throws IOException {
		l=in.readLong();
	}

	public void write(DataOutputStream out) throws IOException {
		out.writeLong(l);
	}
	
	public long get() {
		return l;
	}
	
	@Override
	public boolean equals(Object o) {
		if (o instanceof LongWritable) {
			return l==((LongWritable)o).get();
		}
		return false;
	}
	
	public int compareTo(Object o) {
		LongWritable t = (LongWritable) o;
		if (l==t.get()) return 0;
		if (l<t.get()) return -1;
		return 1;
	}
	
	@Override
	public String toString() {
		return "" + l;
	}
	
}
